<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
  <head>
    <title>publish attributes</title>
    <script src="../../../webcomponentsjs/webcomponents.js"></script>
    <link rel="import" href="../../polymer.html">
    <script src="../../../tools/test/htmltest.js"></script>
    <script src="../../../tools/test/chai/chai.js"></script>
  </head>
  <body>

    <polymer-element name="x-foo" attributes="Foo baz" constructor="XFoo">
      <script>
        Polymer('x-foo');
      </script>
    </polymer-element>

    <polymer-element name="x-bar" extends="x-foo" attributes="Bar" constructor="XBar">
      <script>
        Polymer('x-bar');
      </script>
    </polymer-element>

    <polymer-element name="x-zot" extends="x-bar" constructor="XZot">
      <script>
        Polymer('x-zot', {
          publish: {
            zot: 3
          }
        });
      </script>
    </polymer-element>

    <polymer-element name="x-squid" extends="x-zot" attributes="squid" constructor="XSquid">
      <script>
        Polymer('x-squid', {
          publish: {
            baz: 13,
            zot: 5,
            squid: 7
          }
        });
      </script>
    </polymer-element>

  <script>
      var assert = chai.assert;
      document.addEventListener('polymer-ready', function() {
        
        // tests publishAttributes
        
        assert.deepEqual(
            XFoo.prototype.publish, 
            {Foo: undefined, baz: undefined}, 1);
        assert.deepEqual(
            XBar.prototype.publish, 
            {Foo: undefined, baz: undefined, Bar: undefined}, 2);
        assert.deepEqual(
            XZot.prototype.publish, 
            {Foo: undefined, baz: undefined, Bar: undefined, zot: 3}, 3);
        assert.deepEqual(
            XSquid.prototype.publish, 
            {Foo: undefined, baz: 13, Bar: undefined, zot: 5, squid: 7}, 4);

        // tests publishProperties
            
        assert.equal(XSquid.prototype.Foo, null);
        assert.equal(XSquid.prototype.baz, 13);
        assert.equal(XSquid.prototype.Bar, null);
        assert.equal(XSquid.prototype.zot, 5);
        assert.equal(XSquid.prototype.squid, 7);

        done();
      });
    </script>
  </body>
</html>
